package com.yqd.lesson.actor.serven

import akka.actor.{Actor, ActorLogging, ActorRef, Props}
import akka.dispatch.{BoundedMessageQueueSemantics, RequiresMessageQueue}
import akka.routing.{FromConfig, RoundRobinPool}
import com.yqd.lesson.actor.serven.Main.system

object Sender {
  //def props: Props = Props[Sender].withDispatcher("my-pinned-dispatcher")
  def props: Props = Props[Sender]

  //配置文件实现
  val router: ActorRef = system.actorOf(FromConfig.props(Props[Receiver]), "router1")

  //代码实现
  //val router: ActorRef = system.actorOf(RoundRobinPool(5).props(Props[Receiver]), "router2")
}

class Sender extends Actor with ActorLogging {
  import Sender._

  def receive = {
    case msg:String =>
      router ! msg
  }
}
